package main

import (
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
	"fmt"
	"gorm_demo/model"
)

func main() {
	db, err := gorm.Open("mysql", "root:123456@tcp(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Local")
	db.LogMode(true)
	if err != nil {
		fmt.Println(err.Error())
	}

	user := model.User{}
	db.First(&user)
	fmt.Println(user)

	db.Delete(user)

	db.Where(model.User{Age: 18}).Delete(model.User{})
}
